<script>
import {Base64} from "js-base64";

export default {
  name: "FileShow",
  data() {
    return {
      pageUrl:null,
    }
  },
  props: {
    url: {
      type: String,
      default: ''
    },
    width: {
      type: Number,
      default: 1000
    },
    height: {
      type: Number,
      default: 800
    }
  },
  created() {
    if(this.url == null|| this.url === ''){
      this.$message.error('文件错误');
    }
    this.pageUrl = 'http://117.72.42.92:8012/onlinePreview?url=' + encodeURIComponent(Base64.encode(this.url));
    console.log(this.pageUrl);
  }
}
</script>

<template>
  <div class="file">
    <iframe :src="pageUrl" :style="`min-width: ${width}px;min-height: ${height}px`" ></iframe>
  </div>
</template>

<style scoped lang="scss">
.file{
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%
}
</style>
